home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #5 / Amiga Plus CD - 2000 - No. 5.iso / Tools / Misc / EZHome / EZHomePrefs < prev    next >
Text File  |  2000-01-01  |  38KB  |  1,107 lines

  1. /* EZHomePrefs
  2. ** This program uses MUIRexx v3.0+
  3. ** $VER: EZHomePrefs 1.00 © 1996-2000 by Jim Hines and Gene Heskett - EzSoft
  4. ** 
  5. ** Fixed bug which prevented creating an action.prefs file when one didn't exist
  6. ** Battreset button now works.
  7. **
  8. ** Fixed the dim gadgets bug
  9. ** Fixed another bug in the dim which was causing an exit if no status was returned.
  10. ** Added user Macro.prefs support. Eventually want to be able to record macros
  11. ** Deleted 'rx' from EZHome startup command as it is now compiled and rx is unnecessary.
  12. ** Now supports ALL statusrequest items including EZHomeD version number.
  13. **
  14. ** v77 Battery Meter and Battery Reset Now functional
  15. ** v78 User Labels kinda working.
  16. ** v79 Commented out the 'do until rc ~= 20' code in the send.
  17. ** v80 Took out the above 'fix' as it was causing problems
  18. ** v81 Took out all references to RexxReqTools.library and replace with MUI calls
  19. **     Still one more to work out though.
  20. ** v82 Text field gadget now allows user to name units. Also sames these. Note that the
  21. **     settings are lost when switching to a new housecode UNLESS prefs were saved first.
  22. **
  23. ** v84 Fixed bugs in prefs files routines.
  24. ** v85 Fixed empty "class" variable problem. Was always replying to a port unnecessarily.
  25. **     This problem also existed in EZCronR4b.
  26. ** v86 Now reselects the previously selected action on refreshes.
  27. ** v87 Fixed a bug that caused an error when loading a new action file. Now resets the
  28. **     last selected action to 0
  29. ** v88 Bumped to match version of ezhome daemon
  30. ** v89 EZHome About Logo now ghosts when about window is opened.
  31. ** v89a Created batterytype vars for alkaline, NiCad and DryCell. Expermenatal at this point.
  32. ** v90 
  33. ** v91 Bug hunting, some non-lighting functions cause exits due to wrong arguments.
  34. **     Such as repeats of the talking clock translation.  Obviously an un-initialized var
  35. **     someplace, but I haven't found it yet...
  36. ** v91.1 Jim Lucia reports he cannot stop it from opening the logging
  37. **     screen/window.
  38. ** v91.2 some housecleaning
  39. ** v91.3 trying to fix housecode stuffs.  Got it!
  40. **
  41. ** V 1.00! Finally ready for Prime Time
  42. **        Oops, Jim Lucia says no, and he is right!  That ones fixed now 5-22-2000 GH
  43. **        5/25/2000 trying to make gui a bit more informative, like an auto update that
  44. **        includes the dimmed status?
  45. */
  46.     VER    = 'EZHomePrefs V1.00 © 1996-2000 by\n Jim Hines and Gene Heskett DBA EzSoft'
  47.     
  48.  
  49.     SIGNAL ON ERROR
  50.     SIGNAL ON IOERR
  51.     SIGNAL ON SYNTAX
  52.     SIGNAL ON HALT
  53.     SIGNAL ON BREAK_C
  54.     OPTIONS FAILAT 20
  55.     OPTIONS RESULTS
  56.  
  57.     if ~show('L','rexxsupport.library') then call addlib('rexxsupport.library', 0, -30)
  58.     if ~show('L','rexxreqtools.library') then call addlib("rexxreqtools.library", 0, -30, 0)
  59.  
  60. /* ========================== GLOBAL VARIABLES ======================== */
  61.     disclose         = 0        /* troubleshooter, set to 0 if no shell is available */
  62.     LF                = '0a'x
  63.     mod             = 0        /* Modified variable */
  64.     CM11A_Time        = 'ERROR'
  65.     CM11A_Day        = 'ERROR'
  66.     CM11A_DayNum    = 'ERROR'
  67.     CM11A_Rev        = 'ERROR'
  68.     Battimer        = 0
  69.     EZHomeD_Ver        = 'NA'
  70.     EZHome_Reg        = 'NA'
  71.     user.0            = 0
  72.     en                = 0            /* Selected action */
  73.     super            = 262144
  74.     alk                = 196608
  75.     nicad            = 131072
  76.     drycel            = 65536
  77.     batterytype     = super
  78.     dimbyte1         = '00'x
  79.     dimbyte2         = '00'x
  80.     devstat1        = '00'x
  81.     devstat2        = '00'x
  82. /*    StatusArray.1    = 'Off'
  83.     StatusArray.2    = 'On'
  84.     StatusArray.3    = 'Dim' */
  85.     StutusArray.0    = 'Off'
  86.     StutusArray.1    = 'On'
  87.     StutusArray.2    = 'Dim'
  88.  
  89.     /* ==========end=========== */
  90.  
  91. /* ========================== MUI VARIABLES ======================== */
  92.     TRUE                                 = 1
  93.     FALSE                                 = 0
  94.     MUIA_Selected                         = 0x8042654b
  95.     MUIA_Menuitem_Shortcut                 = 0x80422030
  96.     MUIA_Disabled                         = 0x80423661
  97. /*    MUIA_Group_Columns                     = 0x8042f416*/
  98. /*    MUIA_Group_VertSpacing                 = 0x8042e1bf*/
  99. /*    MUIA_Group_SameWidth                 = 0x8042b3ec*/
  100. /*    MUIV_Frame_Group                     = 9*/
  101. /*    MUIA_Cycle_Active                     = 0x80421788*/
  102. /*    MUIA_Dropable                         = 0x8042fbce*/
  103.     MUIA_List_Quiet                     = 0x8042d8c7
  104.     MUIA_List_Active                     = 0x8042391c    /* required to get number info from listview */
  105.     MUIM_List_Clear                        = 0x8042ad89    /* Clears listview..duh */
  106. /*    MUIV_List_GetEntry_Active             = -1*/
  107.  
  108.     MUIV_EveryTime = 0x49893131
  109.     MUIV_List_Insert_Bottom = -3
  110.     MUIA_List_Format = 0x80423c0a
  111.     MUIA_Window_ScreenTitle             = 0x804234b0
  112.     MUIM_Application_AboutMUI             = 0x8042d21d            /* MUI Launching Attrs */
  113.     MUIM_Application_OpenConfigWindow     = 0x804299ba
  114.  
  115. /* Battery Timer */
  116.     MUIA_Gauge_Current                     = 0x8042f0dd /* V4  isg LONG              */
  117.     MUIA_Gauge_Divide                     = 0x8042d8df /* V4  isg BOOL              */
  118.     MUIA_Gauge_Horiz                     = 0x804232dd /* V4  i.. BOOL              */
  119.     MUIA_Gauge_Max                         = 0x8042bcdb /* V4  isg LONG              */
  120.  
  121. /* FOR RESELECTION OF LISTS */
  122.  
  123.     MUIM_List_Select                    = 0x804252d8
  124.     MUIV_List_Select_All                = '-2'
  125.     MUIV_List_Select_Off                =  '0'
  126.     MUIV_List_Select_On                    =  '1'
  127.  
  128. /* ========================== Open EZHome.prefs here ======================== */
  129.  
  130.     if exists('EZHome:prefs/EZHome.prefs') then do
  131.         if disclose = 1 then say 'Reading EZHome.prefs'
  132.         call open('gprefs', 'EZHome:Prefs/EZhome.prefs', R)
  133.         plogpath     = readln('gprefs')    /*pref.1*/
  134.         pdevice     = readln('gprefs')    /*pref.2*/
  135.         punit         = readln('gprefs')    /*pref.3*/
  136.         pdefhouset    = readln('gprefs')    /*pref.4*/
  137.         call cvthousehex()                /* Call routine to convert defhousecode from hex. pdefhouse is returned variable */
  138.         plogsw        = readln('gprefs')    /*pref.5*/
  139.         ptstsw        = readln('gprefs')    /*pref.6*/
  140.         call close('gprefs')
  141.     end
  142.     else do
  143.         call message('EZHome.prefs file not found, using defaults')
  144.         plogpath     = 't:ezhlog.txt'
  145.         pdevice     = 'serial.device'
  146.         punit         = '0'
  147.         pdefhouse    = 'A'
  148.         plogsw        = '0'
  149.         ptstsw        = 0
  150.     end
  151.  
  152.     call openprefs()
  153.  
  154. /* ========================== BUILD MUI GUI ======================== */
  155.     address EZHOMEMUI
  156.     window ID Win1 COMMAND """QUIT""" PORT EZHOMEPREFS ATTRS MUIA_Window_ScreenTitle """EZHomePrefs MUI v1.0 ©1998-2000 EZSoft""" TITLE """EZHome - Easy home automation for Amiga."""
  157.         menu LABEL "Project"
  158.             item COMMAND """ldgad""" PORT EZHOMEPREFS ATTRS MUIA_Menuitem_Shortcut L LABEL "Load"
  159.             item COMMAND """svgad""" PORT EZHOMEPREFS ATTRS MUIA_Menuitem_Shortcut S LABEL "Save"
  160.             item COMMAND """about""" PORT EZHOMEPREFS LABEL "About EZHome"
  161.             item COMMAND '"method 'MUIM_Application_AboutMUI' 0"' PORT EZHOMEMUI LABEL "About MUI"
  162.             item COMMAND '"method 'MUIM_Application_OpenConfigWindow'"' PORT EZHOMEMUI LABEL "MUI Settings"
  163.             item COMMAND """QUIT""" PORT EZHOMEPREFS ATTRS MUIA_Menuitem_Shortcut Q LABEL "Quit"
  164.         endmenu
  165.         menu LABEL "Prefs"
  166.             item COMMAND """svglb""" PORT EZHOMEPREFS LABEL "Save Prefs"
  167.         endmenu
  168.         if showlist('A', 'EZCRON')then do
  169.             group REGISTER LABELS "RealTime,Actions,Prefs, Timer"
  170.         end
  171.         else group REGISTER LABELS "RealTime,Actions,Prefs"
  172.             MUIA_Slider_Min = 0x8042e404     /*=========== Build Realtime Page ===========*/
  173.             MUIA_Slider_Max = 0x8042d78a
  174.             MUIA_Slider_Level = 0x8042ae3a
  175.             MUIA_Text_SetMax = 0x80424d0a
  176.             group HORIZ
  177.                 group FRAME
  178.                     group HORIZ
  179.                         label "Housecode"
  180.                         cycle ID rcyc COMMAND """realhouse""" PORT EZHOMEPREFS LABELS "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P"
  181.                     endgroup
  182.                     group HORIZ
  183.                         menu LABEL "Prefs"            /* Pop Up Menu */
  184.                             item COMMAND """svglb""" PORT EZHOMEPREFS LABEL "Save Labels"
  185.                         endmenu
  186.                         group
  187.                             do qq = 1 to 16
  188.                                 /*if hcuser.qq = qq then iterate*/
  189.                                 space
  190.                                 string ID rc.qq HELP """Name Field:\nAllows user to enter\nknown unit names.""" CONTENT hcuser.qq
  191.                             end
  192.                         endgroup
  193.                         group
  194.                             do qq = 1 to 16
  195.                                 /*if hcuser.qq = qq then iterate*/
  196.                                 space
  197.                                 cycle ID _on||qq COMMAND _on||qq PORT EZHOMEPREFS LABELS "Off,On,Dim"
  198.                             end
  199.                         endgroup
  200.                         group
  201.                             do qq = 1 to 16
  202.                                 /*if hcuser.qq = qq then iterate*/
  203.                                 space
  204.                                 /*if hcuser.qq = qq then popslider ID _dm||qq ATTRS MUIA_Disabled 1
  205.                                 else*/ popslider ID _dm||qq COMMAND _dm||qq PORT EZHOMEPREFS ATTRS MUIA_Slider_Min "-9" MUIA_Slider_Max 9
  206.                             end
  207.                         endgroup
  208.                     endgroup
  209.                     group
  210.                         button COMMAND """statusreq""" PORT EZHOMEPREFS LABEL "Status Update"
  211.                     endgroup
  212.                 endgroup    
  213.                 group FRAME
  214.                     button ID about COMMAND 'about' PORT EZHOMEPREFS PICT "EZHome:Images/ezs.iff"
  215.                     group HORIZ
  216.                         label "Last Selected"
  217.                         text ID rlast LABEL "None"
  218.                     endgroup
  219.                     button COMMAND """ralllightson""" PORT EZHOMEPREFS LABEL "AllLightsOn"
  220.                     button COMMAND """ralllightsoff""" PORT EZHOMEPREFS LABEL "AllLightsOff"
  221.                     button COMMAND """rallunitsoff""" PORT EZHOMEPREFS LABEL "AllUnitsOff"
  222.                     /*space*/
  223.                     /*if user.0 ~= 0 then do*/
  224.                     list ID LIST2 TITLE """\033b\033uQuick Macros""" COMMAND """LIST2""" PORT EZHOMEPREFS
  225.                     /*end*/
  226.                     group HORIZ
  227.                         button COMMAND """addmacro""" PORT EZHOMEPREFS LABEL "Add"
  228.                         button COMMAND """delmacro""" PORT EZHOMEPREFS LABEL "Delete"
  229.                     endgroup
  230.                 endgroup
  231.             endgroup
  232.             group ATTRS MUIA_Group_SameWidth MUIV_Frame_Group        /* Monitored Events Page*/
  233.                 group FRAME
  234.                     group HORIZ
  235.                         label "Command"
  236.                         popasl ID args COMMAND """args""" PORT EZHOMEPREFS HELP """This is the command to\n be executed whenan\n X10 command is received."""
  237.                     endgroup
  238.                     group HORIZ
  239.                         label "House"
  240.                         cycle ID hc COMMAND """hc""" PORT EZHOMEPREFS HELP """Housecode""" LABELS "-,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P"
  241.                         cycle ID uc COMMAND """uc""" PORT EZHOMEPREFS HELP """Unitcode""" LABELS "-,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16"
  242.                         label "Unit"
  243.                         cycle ID fnc COMMAND """fnc""" PORT EZHOMEPREFS HELP """Function""" LABELS "-,On,Off,Dim,Bright,AllLightsOn,AllUnitsOn,AllUnitsOff"
  244.                         label "Function"
  245.                         button ID adgad COMMAND """adgad""" PORT EZHOMEPREFS HELP """Adds the current Action\nto the Action list.""" LABEL "Add"
  246.                     endgroup
  247.                     group HORIZ
  248.                         label LEFT "Description"
  249.                         string ID DCSTR COMMAND """descstr""" PORT EZHOMEPREFS
  250.                     endgroup
  251.                 endgroup
  252.                 group
  253.                     list ID """LIST1""" TITLE """\033bAction List""" PORT EZHOMEPREFS HELP """Contains Descriptions of Actions."""
  254.                 endgroup
  255.                 group FRAME
  256.                     group HORIZ
  257.                         button ID newgd COMMAND """newgd""" PORT EZHOMEPREFS HELP """Clears all fields.""" LABEL "Clear/New"
  258.                         button ID ldgad COMMAND """ldgad""" PORT EZHOMEPREFS HELP """Load an Action file"""  LABEL "Load"
  259.                         button ID svgad COMMAND """svgad""" PORT EZHOMEPREFS HELP """Save an Action file""" LABEL "Save"
  260.                     endgroup
  261.                     group HORIZ
  262.                         button ID dlgad COMMAND """dlgad""" PORT EZHOMEPREFS HELP """Delete selected entry.""" LABEL "Delete"
  263.                         button ID test COMMAND """test""" PORT EZHOMEPREFS HELP """Test selected entry.""" LABEL "Test"
  264.                         button ID fresh COMMAND """fresh""" PORT EZHOMEPREFS HELP """Refresh ports.""" LABEL "Refresh"
  265.                     endgroup
  266.                 endgroup
  267.             endgroup
  268.                             /*=========================Build Preferences screen======================*/
  269.             group
  270.                 group FRAME HORIZ
  271.                     label LEFT "Serial Device"
  272.                     string ID devgad CONTENT pdevice
  273.                     label "Unit"
  274.                     string ID unit CONTENT punit
  275.                 endgroup
  276.                 group FRAME
  277.                     group FRAME HORIZ
  278.                         label "Monitored Housecode"
  279.                         cycle ID hcpref COMMAND """sethouse""" PORT EZHOMEPREFS LABELS "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P"
  280.                     endgroup
  281.                     group FRAME HORIZ
  282.                         label "Record Log"
  283.                         check ID logsx COMMAND """logsx""" PORT EZHOMEPREFS ATTRS MUIA_Selected plogsw HELP """Controls whether a log\nis recorded or not."""
  284.                         label "LogPath"
  285.                         string ID loggad CONTENT plogpath
  286.                     endgroup
  287.                     group FRAME HORIZ
  288.                         label 'BattType'
  289.                         cycle ID batyp COMMAND "batterytype" PORT EZHOMEPREFS LABELS "Standard,NiCad,Alkaline,Lithium"
  290.                         button ID batgd COMMAND """batgd""" PORT EZHOMEPREFS LABEL "Battery Reset"
  291.                         label "E"
  292.                         gauge ID batmt ATTRS MUIA_Gauge_Horiz MUI_Frame_Gauge MUIA_Gauge_InfoText '' MUI_Gauge_Current LABEL "Battery Level %ld"
  293.                         label "F"
  294.                         /*object CLASS '"Scale.mui"'*/
  295.                     endgroup
  296.                 endgroup
  297.                 group HORIZ
  298.                     group FRAME
  299.                         button ID scgad COMMAND """scgad""" PORT EZHOMEPREFS LABEL "Set Clock"
  300.                         label CENTER "\033bCM11A Status"
  301.                         text ID CM1
  302.                         text ID CM2
  303.                         text ID CM3
  304.                         text ID CM4
  305.                         button COMMAND """statusreq""" PORT EZHOMEPREFS LABEL "Status Update"
  306.                     endgroup
  307.                     group
  308.                         group FRAME
  309.                             group HORIZ
  310.                                 label "Test Shell"
  311.                                 check ID tstsx COMMAND """tstsx""" PORT EZHOMEPREFS ATTRS MUIA_Selected ptstsw HELP """Determines whether or not\na console is opened when\ntesting actions."""
  312.                             endgroup
  313.                         endgroup
  314.                         button ID svglb COMMAND """svglb""" PORT EZHOMEPREFS LABEL "Save Settings"
  315.                     endgroup
  316.                 endgroup
  317.             endgroup
  318.         endgroup
  319.         group HORIZ
  320.             label "EZHome Daemon Control"
  321.             if showlist('P','EZHOME') then do
  322.                 address EZHomeMUI
  323.                 button ID ezhd COMMAND """ezhd""" PORT EZHOMEPREFS HELP """EZHome daemon switch""" LABEL "Active"
  324.             end
  325.             if ~showlist('P', 'EZHOME') then do
  326.                 address EZHomeMUI
  327.                 button ID ezhd COMMAND """ezhd""" PORT EZHOMEPREFS HELP """EZHome daemon switch""" LABEL "Inactive"
  328.             end
  329.             if showlist('A', 'EZCRON')then do
  330.                 button ID ezcron COMMAND """ezcron""" PORT EZHOMEPREFS HELP """Call EZCron Prefs""" LABEL "EZCron"
  331.             end
  332.             /*button ID abt COMMAND """about""" PORT EZHOMEPREFS HELP """EZHome, by \nEZSoft""" LABEL "About"*/
  333.         endgroup
  334.     endwindow
  335.  
  336.     /*callhook ID DCSTR COMMAND """string ID DCSTR CONTENT %s""" PORT EZHOMEMUI ATTRS MUIA_List_Active MUIV_EveryTime*/
  337.  
  338.     cycle ID hcpref LABELS pdefhouse                /* reset the monitored housecode gad */
  339.     cycle ID rcyc LABELS pdefhouse                    /* reset the realtime housecode gad */
  340.     list ID LIST1 ATTRS MUIA_List_Quiet 1            /* Disable listview redraw */
  341.     do qq = 1 to next
  342.         list ID LIST1 INSERT POS STRING MUIV_List_Insert_Bottom STRING pdesc.qq
  343.     end
  344.     if user.0 ~= 0 then do
  345.         do qq = 1 to user.0                                /* Write Macro Listview */
  346.             list ID LIST2 INSERT POS MUIV_List_Insert_Bottom STRING username.qq
  347.         end
  348.     end
  349.     list ID LIST1 ATTRS MUIA_List_Quiet 0
  350.  
  351.     callhook ID LIST1 COMMAND """LIST1""" PORT EZHOMEPREFS ATTRS MUIA_List_Active MUIV_EveryTime
  352.  
  353.     call openport('EZHOMEPREFS')
  354.     if showlist('P', EZHOME) then do
  355.         call statusrep()
  356.         call devstatus()
  357.     end
  358. /* ========================== MAIN LOOP ======================== */
  359. waitforpkt:
  360.     do forever
  361.         vpkt = 0
  362.         address EZHOMEPREFS
  363.         call waitpkt('EZHOMEPREFS')    /* Wait for a message from the daemon */
  364.         packet = getpkt('EZHOMEPREFS')        /* Get the message */
  365.         if packet ~= '00000000'x then do /* This is not a null message */
  366.             vpkt = 1
  367.             class  = getarg(packet)    /* Get the information about the message */
  368.             if disclose = 1 then say 'Class =' class  /* This MIGHT have been Jim Lucia's auto-open shell! */
  369.             if pos('StatusReturn',class) > 0 then do
  370.                 if words(class) > 1 then do
  371.                      stat.9           = word(class, 2)
  372.                     stat.10          = word(class, 3)
  373.                     devstat1         = x2c(left(stat.9, 2))
  374.                     devstat2         = x2c(right(stat.9, 2))
  375.                     dimbyte1         = x2c(left(stat.10, 2))
  376.                     dimbyte2         = x2c(right(stat.10, 2))
  377.                     CM11A_Time        = word(class, 4)
  378.                     CM11A_Day        = word(class, 5)
  379.                     CM11A_DayNum    = word(class, 6)
  380.                     CM11A_Rev        = word(class, 7)
  381.                     battimer        = word(class, 8)
  382.                     rethouse        = word(class, 9)    
  383.                     EZHomeD_Ver        = word(class, 10)
  384.                     EZHome_Reg        = 'EzHome 'substr(class,50+length(battimer))    /* Compensate for battertime strlen */
  385.                     if vpkt = 1 then call reply(packet,0);vpkt=0
  386.                     call devstatus()
  387.                 end
  388.             end
  389.             /* Actions Window */
  390.             if class = 'args' then call args()
  391.             if class = 'hc' then call hc()
  392.             if class = 'uc' then call uc()
  393.             if class = 'fnc' then call fnc()
  394.             if class = 'descstr' then call descstr2()
  395.             if class = list1 then call list1()
  396.             if class = 'adgad' then call adgad()
  397.             if class = 'newgd' then call newgd()
  398.             if class = 'dlgad' then call delete()
  399.             if class = 'fresh' then call refresh(0)
  400.             if class = 'refresh' then call refresh(1)
  401.             if class = 'svgad' then call svgad()
  402.             if class = 'ldgad' then call ldgad()
  403.             if class = 'test' then call test()
  404.             if class = 'ezhd' then call ezhd()
  405.             if class = 'about' then call about()
  406.             if class = quit then call exiting()
  407.             if class = 'ezcron' then do
  408.                 if exists('EZCron:ezmui') then address command 'run >NIL: execute EZCron:ezmui'
  409.             end
  410.         /* Prefs Window */
  411.             if class = 'sethouse' then call sethouse()
  412.             if class = 'svglb' then call saveprefs()
  413.             if class = 'scgad' then call setclock()
  414.             if class = 'batgd' then call batteryrst()
  415.  
  416.         /* Realtime Window */
  417.             if class = 'realhouse' then call labels()
  418.             if class = list2 then call list2()
  419.             if class = rdims then call rdims()            /* TEMPORARY and no such function! */
  420.  
  421. /* this loop below is doing it the hard way but requires fixes in _on and _dimit for complete speedup */
  422. /* it should be done like this: */
  423.             if pos('_',class) then do
  424.                 if pos('_ON',class)= 1 then do
  425.                     qq = substr(class,4)
  426.                     call _on(qq)
  427.                 end
  428.                 if pos('_DM',class)= 1 then do
  429.                     qq = substr(class,4)
  430.                     call _dimit(qq)
  431.                 end
  432.             end
  433.             if class = 'ralllightson' then call rAllLightsOn()
  434.             if class = 'ralllightsoff' then call rAllLightsOff()
  435.             if class = 'rallunitsoff' then call rAllUnitsOff()
  436.             if class = 'statusreq' then call statusrep()
  437.         /* Macro Stuff */
  438.             if class = 'addmacro' then call AddMacro()
  439.             if class = cancelreq1 then call CancelWin(AddMacWindow)
  440.             if class = 'delmacro' then call DelMacro()    /* is dummy return */
  441.         /* Arexx Commands */
  442.         /* Misc Commands */
  443.             if class = closeabout then call closeabout()
  444.         end
  445.     end
  446.     return
  447.  
  448. /* ============================================================= */
  449.  
  450. DescStr2:
  451.     address EZHOMEMUI
  452.     mod = 1
  453.     string ID DCSTR ; com = result
  454.     pdesc.en = com
  455.     /*list ID LIST1 INSERT POS en STRING MUIV_List_Insert_Bottom pdesc.i*/
  456.     if vpkt = 1 then call reply(packet,0);vpkt=0
  457.     call refresh()
  458.     return
  459.  
  460. list1:
  461.     address EZHOMEMUI
  462.     list ID LIST1 ATTRS MUIA_List_Active
  463.     en = RESULT+1  /* en is the event number */
  464.     list ID LIST1 ; desc = result
  465.     popasl ID args CONTENT pcommand.en
  466.     cycle ID hc LABELS housecode.en
  467.     cycle ID uc LABELS unitcode.en
  468.     cycle ID fnc LABELS pfunc.en
  469.     string ID dcstr CONTENT pdesc.en
  470.     if vpkt = 1 then call reply(packet,0);vpkt=0
  471.     return
  472.  
  473. newgd:    /* Simply clears all fields */
  474.     address EZHOMEMUI
  475.     list ID LIST1 ATTRS MUIA_List_Active
  476.     popasl ID args CONTENT
  477.     cycle ID hc LABELS '-'
  478.     cycle ID uc LABELS '-'
  479.     cycle ID fnc LABELS '-'
  480.     string ID DCSTR CONTENT ''
  481.     if vpkt = 1 then call reply(packet,0);vpkt=0
  482.     return
  483.  
  484. test:
  485.     address EZHOMEMUI
  486.     check ID tstsx ; showit = result
  487.     if showit = '0' then address command 'run >NIL:' pcommand.en
  488.     else address command 'run <NIL: >CON:100/100/400/100/EZHomeTestAction/Close' pcommand.en
  489.     drop showit
  490.     if vpkt = 1 then call reply(packet,0);vpkt=0
  491.     if showlist('P', EZHOME) then do
  492.         call statusrep()
  493.         call devstatus()
  494.     end
  495.     return
  496.  
  497. ezhd:                                /* EZHomeD control */
  498.     address EZHOMEMUI
  499.     if ~showlist('P', 'EZHOME') then address command 'run >nil: EZHome'
  500.     else if showlist('P', 'EZHOME') then address command 'rx "address EZHOME quit"'
  501.     call delay(50)
  502.     call refresh(0)
  503.     if vpkt = 1 then call reply(packet,0);vpkt=0
  504.     return
  505.  
  506. about:
  507.     if vpkt = 1 then call reply(packet,0);vpkt=0
  508.     address EZHOMEMUI
  509.     button ID about ATTRS MUIA_Disabled 1
  510.     AboutWindow = 'window ID about'
  511.     AboutWindow
  512.         group HORIZ
  513.             button PICT "EZHome:Images/ezs.iff" /*TRANS*/ ATTRS MUIA_Background MUII_WindowBack MUIA_Frame MUIV_Frame_None
  514.             text ATTRS MUIA_Background MUII_WindowBack MUIA_Frame MUIV_Frame_None LABEL VER"\nEZHomeD" EZHomeD_Ver "© 1996-2000 EzSoft\n by Jim Hines and Gene Heskett\n\n"EZHome_REG"\nSee docs for more info.\n\nCopyright 1996-2000 EZSoft"
  515.         endgroup
  516.         group HORIZ
  517.             space HORIZ
  518.             button PRESS COMMAND closeabout PORT EZHOMEPREFS ATTRS MUIA_Text_HiChar c2d('O') MUIA_ControlChar c2d('o') LABEL "Ok"
  519.             space HORIZ
  520.         endgroup
  521.     endwindow
  522.     return
  523.  
  524. closeabout:
  525.     if vpkt = 1 then call reply(packet,0);vpkt=0
  526.     address EZHOMEMUI
  527.     AboutWindow CLOSE
  528.     button ID about ATTRS MUIA_Disabled 0
  529.     return
  530.  
  531. ldgad:
  532.     mod = 0
  533.     argname = rtfilerequest('EZHome:ConfigFiles', , 'Pick a config file to load', 'OK', 'rt_reqpos = reqpos_centerscr')
  534.     if argname ~= '' then do
  535.         address command 'copy' argname 'EZHome:prefs/Action.prefs'
  536.         call openprefs()
  537.         en = 0
  538.         call refresh(1)
  539.     end
  540.     if vpkt = 1 then call reply(packet,0);vpkt=0
  541.     return
  542.  
  543. svgad:
  544.     argname = rtfilerequest('EZHome:ConfigFiles', , 'Enter filename to save', OK, 'rt_reqpos = reqpos_centerscr')
  545.     if argname ~= '' then do
  546.         if exists(argname) then do
  547.             /*call rtezrequest('The file'||LF||argname||LF||'already exists.'||LF||'Do you wish to overwrite it?', 'Yes|Cancel', , 'rt_reqpos = reqpos_centerscr')*/
  548.             address EZHOMEMUI
  549.             request TITLE '"EZHome Message"' GADGETS '"Yes|Cancel"' 'The file' argname '\nalready exists.\nDo you wish to overwrite it?'
  550.             if result = 1 then address command 'delete' argname 'FORCE >NIL:'
  551.         end
  552.         call open('aprefs', argname, W)
  553.         do qq = 1 to (count-1)
  554.             call writeln('aprefs',housecode.qq||unitcode.qq','pfunc.qq','pcommand.qq','pdesc.qq',')
  555.         end
  556.         call close('aprefs')
  557.         mod = 0
  558.         address command 'copy' argname 'EZHome:prefs/Action.prefs'
  559.         if vpkt = 1 then call reply(packet,0);vpkt=0
  560.         if showlist('P', EZHOME) then address EZHOME readprefs            /* Notify EZHomeD of the change */
  561.     end
  562.     return
  563.  
  564. refresh:
  565.     if disclose = 1 then say 'refresh: arg(1)='arg(1)
  566.     if vpkt = 1 then call reply(packet,0);vpkt=0
  567.     address EZHOMEMUI
  568.     if ~showlist('P', 'EZHOME') then do
  569.         button ID ezhd LABEL "Inactive"
  570.     end    
  571.     else
  572.     if showlist('P', 'EZHOME') then do    
  573.         button ID ezhd LABEL "Active"
  574.     end
  575.     callhook ID LIST1 COMMAND """nullcommand""" PORT EZHOMEPREFS ATTRS MUIA_List_Active MUIV_EveryTime /* Re-direct Notify */
  576.     method ID LIST1 MUIM_List_Clear
  577.     list ID LIST1 ATTRS MUIA_List_Quiet 1    /* Turn off listview redraw */
  578.     do qq = 1 to count-1
  579.         if pos('!',command.qq) > 0 then list ID LIST1 INSERT POS MUIV_List_Insert_Bottom STRING '\0335'pdesc.qq
  580.         else list ID LIST1 INSERT POS MUIV_List_Insert_Bottom STRING '\0332'pdesc.qq
  581.     end
  582.     list ID LIST1 ATTRS MUIA_List_Quiet 0
  583.     method ID LIST1 MUIM_List_Select en-1 MUIV_List_Select_On 0 /* Select last selected entry */
  584.     callhook ID LIST1 COMMAND """LIST1""" PORT EZHOMEPREFS ATTRS MUIA_List_Active MUIV_EveryTime /* Re-Activate Notify */
  585.     return
  586.  
  587. refreshfile:
  588.     if vpkt = 1 then call reply(packet,0);vpkt=0
  589.     address EZHOMEMUI
  590.     if ~showlist('P', 'EZHOME') then do
  591.         button ID ezhd LABEL "Inactive"
  592.     end    
  593.     else
  594.     if showlist('P', 'EZHOME') then do    
  595.         button ID ezhd LABEL "Active"
  596.     end
  597.     callhook ID LIST1 COMMAND LIST1 PORT EZHOMEPREFS ATTRS MUIA_List_Active MUIV_EveryTime /* Re-direct Notify */
  598.     method ID LIST1 MUIM_List_Clear
  599.         do qq = 1 to count
  600.         drop phcode.qq
  601.         drop pfunc.qq
  602.         drop pcommand.qq
  603.         drop pdesc.qq
  604.         drop housecode.qq
  605.         drop unitcode.qq
  606.     end
  607.     callhook ID LIST1 COMMAND LIST1 PORT EZHOMEPREFS ATTRS MUIA_List_Active MUIV_EveryTime /* Re-Activate Notify */
  608.  
  609.     call openprefs()                        /* Re-read action.prefs */
  610.     list ID LIST1 ATTRS MUIA_List_Quiet 1    /* Re-Insert listview */
  611.     do qq = 1 to next
  612.         list ID LIST1 INSERT POS STRING MUIV_List_Insert_Bottom STRING pdesc.qq
  613.     end
  614.     list ID LIST1 ATTRS MUIA_List_Quiet 0
  615.     return
  616.  
  617. delete:
  618.     if vpkt = 1 then call reply(packet,0);vpkt=0
  619.     address EZHOMEMUI
  620.     mod = 1
  621.     MUIA_List_Active          = '0x8042391c'
  622.     MUIA_List_Entries         = '0x80421654'
  623.     MUIM_Busy_Move            = '0x80020001'
  624.  
  625.     list ID LIST1 ATTRS MUIA_List_Active ;     position = result+1            /* Get position to delete */
  626.     list ID LIST1 POS position ; line = result                            /* Get line content to delete */
  627.     list ID LIST1 POS position-1 STRING                                    /* Delete line in list */
  628.     list ID LIST1 ATTRS MUIA_List_Entries ;    newentries = result            /* Update counters */
  629.  
  630.     do qq = (position+1) to count
  631.         rr = qq-1
  632.         phcode.rr    = phcode.qq
  633.         pfunc.rr    = pfunc.qq
  634.         pcommand.rr    = pcommand.qq
  635.         pdesc.rr    = pdesc.qq
  636.         housecode.rr = housecode.qq
  637.         unitcode.rr    = unitcode.qq
  638.     end
  639.     drop phcode.count pfunc.count pcommand.count pdesc.count housecode.count unitcode.count
  640.     count = count - 1
  641.     return
  642.  
  643. args:
  644.     if vpkt = 1 then call reply(packet,0);vpkt=0
  645.     address EZHOMEMUI
  646.     mod = 1
  647.     list ID LIST1 ATTRS MUIA_List_Active ; position = result+1
  648.     popasl ID args ; comm = result
  649.     pcommand.position = comm
  650.     return
  651.  
  652. hc:
  653.     if vpkt = 1 then call reply(packet,0);vpkt=0
  654.     address EZHOMEMUI
  655.     mod = 1
  656.     list ID LIST1 ATTRS MUIA_List_Active ; position = result+1
  657.     cycle ID hc ; hcode = result
  658.     phcode.position = hcode||unitcode.position
  659.     housecode.position = hcode
  660.     return
  661.  
  662. uc:
  663.     if vpkt = 1 then call reply(packet,0);vpkt=0
  664.     address EZHOMEMUI
  665.     mod = 1
  666.     list ID LIST1 ATTRS MUIA_List_Active ; position = result+1
  667.     cycle ID uc ; ucode = result
  668.     pucode.position = housecode.position||ucode
  669.     unitcode.position = ucode
  670.     return
  671.  
  672. fnc:
  673.     if vpkt = 1 then call reply(packet,0);vpkt=0
  674.     address EZHOMEMUI
  675.     mod = 1
  676.     list ID LIST1 ATTRS MUIA_List_Active ; position = result+1
  677.     cycle ID fnc ; fcode = result
  678.     pfunc.position = fcode
  679.     return
  680.  
  681. adgad:
  682. /*    call auxwin() */
  683.     if vpkt = 1 then call reply(packet,0);vpkt=0
  684.     address EZHOMEMUI
  685.     mod = 1
  686.     popasl ID args ; argstmp = result
  687.     if argstmp = '' then do
  688.         call message('No Command Entered')
  689.         return
  690.     end
  691.     cycle ID hc ; hctmp = result
  692.     cycle ID uc ; uctmp = result
  693.     cycle ID fnc ; fnctmp = result
  694.     desc = rtgetstring(,'Please Enter a Description', 'Description Requester', 'Okay|Cancel')
  695.     if rtresult == 1 then desc = desc
  696.     if rtresult == 0 then return /* call waitforpkt() */
  697.  
  698.     list ID LIST1 NODUP POS MUIV_List_Insert_Bottom INSERT STRING desc    /* Insert new item */
  699.  
  700.     if count = 0 then do            /* Take care of very first entry */
  701.         phcode.1    = hctmp||uctmp
  702.         pfunc.1        = fnctmp
  703.         pcommand.1    = argstmp
  704.         pdesc.1        = desc
  705.         housecode.1    = hctmp
  706.         unitcode.1    = uctmp
  707.         count = count + 1
  708.     end
  709.     else do
  710.         phcode.count    = hctmp||uctmp
  711.         pfunc.count        = fnctmp
  712.         pcommand.count    = argstmp
  713.         pdesc.count        = desc
  714.         housecode.count    = hctmp
  715.         unitcode.count    = uctmp
  716.     end
  717.     count = count+1
  718.     return
  719.  
  720.  
  721. /* ================= REALTIME WINDOW =================== */
  722. labels:
  723.     if vpkt = 1 then call reply(packet,0);vpkt=0
  724.     address EZHOMEMUI
  725.     cycle ID rcyc ; rhouse = result
  726.     if exists('EZHome:prefs/Labels/HC_'rhouse'.prefs') then do
  727.         call open('hcconfig','EZHome:Prefs/Labels/HC_'rhouse'.prefs','R')
  728.         do qq = 1 to 16
  729.             hcuser.qq = readln('hcconfig')
  730.         end
  731.         call close('hcconfig')
  732.     end
  733.     else do qq = 1 to 16
  734.         hcuser.qq = qq
  735.     end
  736.     do qq = 1 to 16
  737.         string ID rc.qq CONTENT hcuser.qq
  738.     end
  739.     return    
  740.  
  741. list2:
  742.     if vpkt = 1 then call reply(packet,0) ; vpkt=0
  743.     address EZHOMEMUI
  744.     list ID LIST2 ATTRS MUIA_List_Active
  745.     en = RESULT+1  /* en is the event number */
  746.     address command 'run >NIL:' user.en
  747.     return
  748.  
  749. _on:
  750.     if vpkt = 1 then call reply(packet,0) ; vpkt=0
  751.     if ~showlist('P',EZHOME) then do
  752.         call message('EZHome Daemon is not running')
  753.         return
  754.     end
  755.     address EZHOMEMUI
  756.     cycle ID rcyc ; rhouse = result
  757.     cycle ID _on||qq ; func = result
  758.     if disclose = 1 then say '_on: func='func 'arg(1)='arg(1) 'len(arg(1)='length(arg(1))' : send 'rhouse||arg(1) upper(func)
  759.     if func ~= 'Dim' then address EZHOME send rhouse||arg(1) upper(func)    /* Send it again if errored */
  760.     text ID rlast LABEL rhouse||qq                /* write the text gad */
  761.     /*if func = 'Off' then popslider ID _dm||qq ATTRS MUIA_Slider_Level 0*/
  762.     return
  763.  
  764. _dimit:
  765.     if vpkt = 1 then call reply(packet,0);vpkt=0
  766.     if ~showlist('P',EZHOME) then do
  767.         call message('EZHome Daemon is not running')
  768.         return
  769.     end    /* else its running */
  770.     address EZHOMEMUI
  771.     cycle ID rcyc ; rhouse = result
  772.     cycle ID _on||qq ; tfunc = result            /* save current button status */
  773.     text ID rlast LABEL rhouse||qq                /* write the text gad */
  774.     popslider ID _dm||qq
  775.     rdimlevel = result
  776.     if pos('-', rdimlevel) > 0 then do
  777.         func = 'DIM'
  778.         rdimlevel = delstr(rdimlevel,1,1)
  779.     end
  780.     else func = 'BRIGHT'
  781.     if tfunc = 'Off' then do
  782.     /* if off, first we turn it on, then we set brightness but we need to shut the daemon up for this */
  783.         call closeport('EZHOMEPREFS')    /* make us dissappear, also saves beaucoup time */
  784.         if disclose = 1 then say '_dimit: address EZHOME send' rhouse||qq 'ON'
  785.         address EZHOME send rhouse||qq 'ON'
  786.         call openport('EZHOMEPREFS')
  787.     end
  788.      /* it was already on, (or dimmed) so do this only */
  789.     if disclose = 1 then say '_dimit: address EZHOME send' rhouse||qq upper(func) rdimlevel
  790.     address EZHOME send rhouse||qq upper(func) rdimlevel
  791.     return
  792.  
  793. rAllLightsOn:
  794.     if vpkt = 1 then call reply(packet,0);vpkt=0
  795.     address EZHOMEMUI
  796.     cycle ID rcyc ; rhouse = result
  797.     if ~showlist('P',EZHOME) then call message('EZHome Daemon is not running')
  798.     else address EZHOME send rhouse'1' AllLightsOn
  799.     return
  800.  
  801. rAllLightsOff:
  802.     if vpkt = 1 then call reply(packet,0);vpkt=0
  803.     address EZHOMEMUI
  804.     cycle ID rcyc ; rhouse = result
  805.     if ~showlist('P',EZHOME) then call message('EZHome Daemon is not running')
  806.     else address EZHOME send rhouse'1' AllLightsOff
  807.     return
  808.  
  809. rAllUnitsOff:
  810.     if vpkt = 1 then call reply(packet,0);vpkt=0
  811.     address EZHOMEMUI
  812.     cycle ID rcyc ; rhouse = result
  813.     if ~showlist('P',EZHOME) then call message('EZHome Daemon is not running')
  814.     else address EZHOME send rhouse'1' AllUnitsOff
  815.     return
  816.  
  817. AddMacro:
  818.     if vpkt = 1 then call reply(packet,0);vpkt=0
  819.     address EZHOMEMUI
  820. /*    button ID dtwin ATTRS MUIA_Disabled 1*/
  821.     AddMacWindow = window ID AddMac ATTRS MUIA_Window_ScreenTitle """EZHomePrefs v1.0 beta by Jim Hines. ©1998 EZSoft""" TITLE """Add Macro"""
  822.     AddMacWindow
  823.         group
  824.             label CENTER 'Enter Macro Definition\nUse format \033bLabel,Field'
  825.             string ID admac COMMAND 'addmacro' PORT EZHOMEPREFS
  826.         endgroup
  827.         group HORIZ
  828.             button LABEL "Okay"
  829.             button COMMAND cancelreq1 PORT EZHOMEPREFS LABEL "Cancel"
  830.         endgroup
  831.     endwindow
  832.     return
  833.  
  834. CancelWin:                    /* This is made to work as generic as possible */
  835.     if vpkt = 1 then call reply(packet,0);vpkt=0
  836.     address EZHOMEMUI
  837.     tmp = arg(1)
  838.     tmp CLOSE
  839.     drop tmp
  840.     return
  841.  
  842. DelMacro:
  843.     if vpkt = 1 then call reply(packet,0);vpkt=0
  844.     return
  845.  
  846. /* ================= PREFERENCES WINDOW =================== */
  847.  
  848. sethouse:
  849.     if vpkt = 1 then call reply(packet,0);vpkt=0
  850.     address EZHOMEMUI
  851.     cycle ID hcpref ; hcprefs = result
  852.     IF disclose = 1 then say 'sethouse: hcprefs='hcprefs
  853.     if showlist('P', EZHOME) then do
  854.         if disclose = 1 then say 'sethouse: address EZHOME sethouse' hcprefs
  855.         address EZHOME SETHOUSE hcprefs
  856.     end
  857.     cycle ID rcyc LABEL hcprefs            /* Set Realtime House */
  858.     drop hcprefs
  859.     return
  860.  
  861. saveprefs:                            /* Save Global Prefs */
  862.     if vpkt = 1 then call reply(packet,0);vpkt=0
  863.     address EZHOMEMUI
  864.     string ID loggad    ; pref.1    = result
  865.     string ID devgad     ; pref.2     = result
  866.     string ID unit         ; pref.3     = result
  867.     cycle ID hcpref     ; tmppref    = result ; call cvthouseasc() /* pref.4 is returned var */
  868.     check ID logsx         ; pref.5     = result
  869.     check ID tstsx        ; pref.6     = result
  870.     call open('gprefs', 'EZHome:Prefs/ezhome.prefs', W)
  871.     do i = 1 to 6
  872.         call writeln('gprefs',pref.i)
  873.     end
  874.     call close('gprefs')
  875.         /* Save Label Names */
  876.     cycle ID rcyc ; rhouse = result
  877.     call open('lprefs', 'EZHome:Prefs/Labels/HC_'rhouse'.prefs', W)
  878.     do qq = 1 to 16
  879.         string ID rc.qq ; read.qq = result
  880.         call writeln('lprefs',read.qq)
  881.     end
  882.     call close('lprefs')
  883.     if showlist('P', EZHOME) then address EZHOME readprefs
  884.     return
  885.  
  886. setclock:
  887.     if vpkt = 1 then call reply(packet,0);vpkt=0
  888.     if showlist('P', EZHOME) then address EZHOME setclock
  889.     return
  890.  
  891. batteryrst:
  892.     if vpkt = 1 then call reply(packet,0);vpkt=0
  893.     if showlist('P', EZHOME) then do
  894.         address EZHOMEMUI
  895.         request TITLE '"Battery Timer Reset"' GADGETS '"Yes|Cancel"' '"\033cThis command should only be\nissued after installing new batteries.\nAre you sure?"'
  896.         if result = 1 then address EZHOME battreset
  897.         call statusrep()
  898.         call devstatus()
  899.     end
  900.     else call message('EZHome Daemon is not running')
  901.     return
  902.  
  903. /* ================= */
  904. openprefs:                            /* Open Action Prefs */
  905.     if vpkt = 1 then call reply(packet,0);vpkt=0
  906.     next = 0
  907.     count = 0                        /* Keeps track of amount of entries */
  908.     if disclose = 1 then say 'Reading Action.prefs'
  909.     if exists('EZHome:Prefs/Action.prefs') then do
  910.         call open('aprefs', 'EZHome:Prefs/Action.prefs', R)
  911.         do until eof('aprefs')
  912.             linein = readln('aprefs')
  913.             if pos(';',linein) = 1 then iterate
  914.             next = next + 1
  915.             count = count + 1
  916.             parse var linein line ';'
  917.             parse var line phcode.next','pfunc.next','pcommand.next','pdesc.next','
  918.             housecode.next = left(phcode.next,1)
  919.             if length(phcode.next) = 3 then do
  920.                 unitcode.next = right(phcode.next,2)
  921.             end
  922.             else unitcode.next = right(phcode.next,1)
  923.         end
  924.         call close('aprefs')
  925.     end
  926.     else call message('No Action.prefs file exists')
  927.  
  928. /* Read Macro Prefs */
  929.     next2 = 0
  930.     if disclose = 1 then say 'Reading Macro.prefs'
  931.     if exists('EZHome:Prefs/Macro.prefs') then do
  932.         call open('mprefs', 'EZHome:Prefs/Macro.prefs', R)
  933.         do until eof('mprefs')
  934.             linein = readln('mprefs')
  935.             if pos(';',linein) = 1 then iterate
  936.             next2 = next2 + 1
  937.             parse var linein line ';'
  938.             parse var line username.next2','user.next2
  939.         end
  940.         call close('mprefs')
  941.         user.0 = next2
  942.     end
  943.  
  944. /* Read NameCode Prefs */
  945.     if exists('EZHome:prefs/Labels/HC_'pdefhouse'.prefs') then do
  946.         call open('hcconfig','EZHome:Prefs/Labels/HC_'pdefhouse'.prefs','R')
  947.         do qq = 1 to 16
  948.             hcuser.qq = readln('hcconfig')
  949.         end
  950.         call close('hcconfig')
  951.     end
  952.     else do qq = 1 to 16
  953.         hcuser.qq = qq
  954.     end
  955.     return
  956.  
  957. auxwin:
  958.     if vpkt = 1 then call reply(packet,0);vpkt=0
  959.     address EZHOMEMUI
  960.     AuxWindow = "window ID Aux"
  961.     AuxWindow
  962.         label CENTER 'Please enter a description'
  963.         string ID auxst
  964.         group HORIZ
  965.             button COMMAND """test9""" PORT EZHOMEPREFS label 'Okay'
  966.             button COMMAND """"AuxWindow" CLOSE""" PORT EZHOMEMUI ATTRS MUIA_Text_HiChar c2d('O') MUIA_ControlChar c2d('o') label 'Cancel'
  967.         endgroup
  968.     endwindow
  969.     return
  970.  
  971. cvthousehex:
  972.     if pdefhouset = '6' then pdefhouse = 'A'
  973.     if pdefhouset = 'E' then pdefhouse = 'B'
  974.     if pdefhouset = '2' then pdefhouse = 'C'
  975.     if pdefhouset = 'A' then pdefhouse = 'D'
  976.     if pdefhouset = '1' then pdefhouse = 'E'
  977.     if pdefhouset = '9' then pdefhouse = 'F'
  978.     if pdefhouset = '5' then pdefhouse = 'G'
  979.     if pdefhouset = 'D' then pdefhouse = 'H'
  980.     if pdefhouset = '7' then pdefhouse = 'I'
  981.     if pdefhouset = 'F' then pdefhouse = 'J'
  982.     if pdefhouset = '3' then pdefhouse = 'K'
  983.     if pdefhouset = 'B' then pdefhouse = 'L'
  984.     if pdefhouset = '0' then pdefhouse = 'M'
  985.     if pdefhouset = '8' then pdefhouse = 'N'
  986.     if pdefhouset = '4' then pdefhouse = 'O'
  987.     if pdefhouset = 'C' then pdefhouse = 'P'
  988.     return
  989.  
  990. cvthouseasc:
  991.     if tmppref = 'A' then pref.4 = '6' 
  992.     if tmppref = 'B' then pref.4 = 'E'
  993.     if tmppref = 'C' then pref.4 = '2'
  994.     if tmppref = 'D' then pref.4 = 'A'
  995.     if tmppref = 'E' then pref.4 = '1'
  996.     if tmppref = 'F' then pref.4 = '9'
  997.     if tmppref = 'G' then pref.4 = '5'
  998.     if tmppref = 'H' then pref.4 = 'D'
  999.     if tmppref = 'I' then pref.4 = '7'
  1000.     if tmppref = 'J' then pref.4 = 'F'
  1001.     if tmppref = 'K' then pref.4 = '3'
  1002.     if tmppref = 'L' then pref.4 = 'B'
  1003.     if tmppref = 'M' then pref.4 = '0'
  1004.     if tmppref = 'N' then pref.4 = '8'
  1005.     if tmppref = 'O' then pref.4 = '4'
  1006.     if tmppref = 'P' then pref.4 = 'C'
  1007.     return
  1008.  
  1009. /* ================= REALTIME WINDOW =================== */
  1010.  
  1011. statusrep:
  1012.     if vpkt = 1 then call reply(packet,0);vpkt=0
  1013.     if showlist('P',EZHOME) then address EZHOME status
  1014.     else do
  1015.         call message('EZHome Daemon is not running')
  1016.         return
  1017.     end
  1018.     return
  1019.  
  1020. devstatus:    /* Get devstatus/dimstatus */
  1021.     if vpkt = 1 then call reply(packet,0);vpkt=0
  1022.     address EZHOMEMUI
  1023. /*0*/
  1024.     bit = MAX(bittst(devstat1,0),(bittst(DimByte1,0)*2))
  1025.     cycle ID _on13 LABELS StutusArray.bit
  1026.     bit = MAX(bittst(devstat2,0),(bittst(DimByte2,6)*0))
  1027.     cycle ID _on14 LABELS StutusArray.bit
  1028. /*1*/
  1029.     bit = MAX(bittst(devstat1,1),(bittst(DimByte1,1)*2))
  1030.     cycle ID _on5 LABELS StutusArray.bit
  1031.     bit = MAX(bittst(devstat2,1),(bittst(DimByte2,1)*2))
  1032.     cycle ID _on6 LABELS StutusArray.bit
  1033. /*2*/
  1034.     bit = MAX(bittst(devstat1,2),(bittst(DimByte1,2)*2))
  1035.     cycle ID _on3 LABELS StutusArray.bit
  1036.     bit = MAX(bittst(devstat2,2),(bittst(DimByte2,2)*2))
  1037.     cycle ID _on4 LABELS StutusArray.bit
  1038. /*3*/
  1039.     bit = MAX(bittst(devstat1,3),(bittst(DimByte1,3)*2))
  1040.     cycle ID _on11 LABELS StutusArray.bit
  1041.     bit = MAX(bittst(devstat2,3),(bittst(DimByte2,3)*2))
  1042.     cycle ID _on12 LABELS StutusArray.bit
  1043. /*4*/
  1044.     bit = MAX(bittst(devstat1,4),(bittst(DimByte1,4)*2))
  1045.     cycle ID _on15 LABELS StutusArray.bit
  1046.     bit = MAX(bittst(devstat2,4),(bittst(DimByte2,4)*2))
  1047.     cycle ID _on16 LABELS StutusArray.bit
  1048. /*5*/
  1049.     bit = MAX(bittst(devstat1,5),(bittst(DimByte1,5)*2))
  1050.     cycle ID _on7 LABELS StutusArray.bit
  1051.     bit = MAX(bittst(devstat2,5),(bittst(DimByte2,5)*2))
  1052.     cycle ID _on8 LABELS StutusArray.bit
  1053. /*6*/
  1054.     bit = MAX(bittst(devstat1,6),(bittst(DimByte1,6)*2))
  1055.     cycle ID _on1 LABELS StutusArray.bit
  1056.     bit = MAX(bittst(devstat2,6),(bittst(DimByte2,6)*2))
  1057.     cycle ID _on2 LABELS StutusArray.bit
  1058. /*7*/
  1059.     bit = MAX(bittst(devstat1,7),(bittst(DimByte1,7)*2))
  1060.     cycle ID _on9 LABELS StutusArray.bit
  1061.     bit = MAX(bittst(devstat2,7),(bittst(DimByte2,7)*2))
  1062.     cycle ID _on10 LABELS StutusArray.bit
  1063. /*MISC*/
  1064.     text ID CM1 LABEL "\033b"CM11A_Time
  1065.     text ID CM2 LABEL CM11A_Day
  1066.     text ID CM3 LABEL "It is" CM11A_DayNum "days into this year"
  1067.     text ID CM4 LABEL "CM11A Revision" CM11A_Rev
  1068.     batlevel = (1 - (battimer / batterytype)) * 100
  1069.     gauge ID batmt ATTRS MUIA_Gauge_Current batlevel MUIA_Gauge_Horiz LABEL "Battery Level %ld"        /* Set battery strength meter   */
  1070.     cycle ID rcyc LABEL rethouse            /* Set Realtime House */
  1071.     cycle ID hcpref LABEL rethouse            /* Set Monitored House */
  1072.     return
  1073.  
  1074. /* ================= */
  1075.  
  1076. message: procedure
  1077.     /*call rtezrequest(arg(1),'OK','EZHome Message','rtez_flags=ezreqf_centertext')*/
  1078.     if vpkt = 1 then call reply(packet,0);vpkt=0
  1079.     address EZHOMEMUI
  1080.     request TITLE '"EZHome Message"' GADGETS '"Okay"' arg(1)
  1081.     return
  1082.  
  1083. syntax:
  1084. ioerr:
  1085. error:
  1086.     errorrc = RC
  1087.     address EZHOMEMUI
  1088.     request TITLE '"EZHomePrefs Fatal Error"' GADGETS '"Okay"' 'EZHomePrefs has exited with an error.\nLine' SIGL '- -' ERRORTEXT(errorrc)
  1089.     call exiting()
  1090.  
  1091. exiting:
  1092. break_c:
  1093.     if vpkt = 1 then call reply(packet,0)
  1094.     if mod = 1 then do
  1095.         address EZHOMEMUI
  1096.         request TITLE '"EZHome Message"' GADGETS '"Yes|No"' '"File has changed.\nDo you want to save it?"'
  1097.         if result = 1 then call svgad()
  1098.     end
  1099.     if ~(showlist('P','EZHOME')) then do
  1100.         address EZHOMEMUI
  1101.         request TITLE '"EZHome Message"' GADGETS '"Yes|No"' '"EZHome Daemon is not running.\nDo you want to run it?"'
  1102.         if result = 1 then address command 'run >nil: EZHome'
  1103.     end
  1104.     call closeport('EZHOMEPREFS')
  1105.     address EZHOMEMUI quit            /* Shut down MUIREXX... */
  1106.     exit
  1107.